﻿//-----------------------------------------------------------------------
// <copyright file="ISceneManager.cs" company="Nathan Miller">
// Copyright (c) Nathan Miller.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
//-----------------------------------------------------------------------
namespace TileTool.Scene
{
    using System;
    using System.Collections.Generic;
    using TileTool.Render;
    using TileTool.Scene.Collision;
    using TileTool.Scene.Entity;

    /// <summary>
    /// Scene interface.
    /// </summary>
    public interface ISceneManager
    {
        #region Events

        /// <summary>
        /// Event triggered when an entity changed.
        /// </summary>
        event EntityChanged EntityChanged;

        #endregion

        #region Properties

        /// <summary>
        /// Gets the current selection as a read-only collection.
        /// </summary>
        IEntityCollection Selection
        {
            get;
        }

        /// <summary>
        /// Gets all entities in the scene as a read-only collection.
        /// </summary>
        IEntityCollection AllEntities
        {
            get;
        }

        #endregion

        #region Methods - Entity management

        /// <summary>
        /// Clear the scene and remove all entities from it. Must send a ISceneClearedMessage
        /// after a successful call.
        /// </summary>
        void Clear();

        /// <summary>
        /// Add the passed entities to the scene. Must send an ISceneEntityAddedMessage message
        /// on a successful add.
        /// 
        /// Added entities should have their Scene set to the scene manager.
        /// </summary>
        /// <param name="ents">Entities to add to the scene.</param>
        void AddEntities(IEntityCollection ents);

        /// <summary>
        /// Remove the passed entities from the scene. Must send a ISceneEntityRemovedMessage message
        /// on a successful remove.
        /// 
        /// Removed entities should have their Scene set to null.
        /// </summary>
        /// <param name="ents">Entities to remove from the scene.</param>
        void RemoveEntities(IEntityCollection ents);

        /// <summary>
        /// Set the selection to the passed collection of entities.
        /// 
        /// A copy of the passed entity collection will be made.
        /// 
        /// A ISceneSelectionChangedMessage must be sent on a successful selection change.
        /// </summary>
        /// <param name="selection">Collection of entities to set the selection to.</param>
        void SetSelection(IEntityCollection selection);

        #endregion

        #region Methods - Render

        /// <summary>
        /// Draw the entities in the scene with the passed renderer.
        /// </summary>
        /// <param name="renderData">Rendering data. Always non-null.</param>
        void Draw(IRenderData renderData);

        #endregion

        #region Methods - Collision

        /// <summary>
        /// Handle a collision request.
        /// </summary>
        /// <param name="req">Collision request.</param>
        /// <returns>Returns a collision result object. Will always be non-null.</returns>
        CollisionResult HandleCollision(CollisionRequest req);

        #endregion
    }
}
